package logic

import (
	"activity/activityRpc/activityRpc"
	"context"

	"activity/api/internal/svc"
	"activity/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddActivityLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAddActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddActivityLogic {
	return &AddActivityLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AddActivityLogic) AddActivity(req *types.AddActivityRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	addActivity, err := l.svcCtx.ActivityRpc.AddActivity(l.ctx, &activityRpc.AddActivityRequest{
		Title:         req.Title,
		ActivityImage: req.ActivityImage,
		Info:          req.Info,
		UserId:        req.UserId,
		Reply:         req.Reply,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "活动发布成功",
		Code:    200,
		Data:    addActivity,
	}, nil
}
